package com.cytech.cloudclinic.adapter;

import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.cytech.cloudclinic.R;
import com.cytech.cloudclinic.bean.DrugTag;

import java.util.List;

public class DrugTagAdapter extends BaseQuickAdapter<DrugTag, BaseViewHolder> {
    private int currentPos = 0;

    public DrugTagAdapter(List<DrugTag> data) {
        super(R.layout.item_drug_category_child, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, DrugTag drugTag) {
        TextView lableTv = baseViewHolder.getView(R.id.item_drug_category_name);
        lableTv.setText(drugTag.name);

        if(baseViewHolder.getAdapterPosition()==currentPos){
            lableTv.setBackground(ContextCompat.getDrawable(getContext(),R.drawable.shape_round_real_bg_e9f2fe));
            lableTv.setTextColor(ContextCompat.getColor(getContext(),R.color.colorPrimary));
        }else{
            lableTv.setBackground(ContextCompat.getDrawable(getContext(),R.drawable.shape_round_real_bg_gray_10));
            lableTv.setTextColor(ContextCompat.getColor(getContext(),R.color.color_333333));
        }
    }

    public void setCurrentPos(int currentPos) {
        this.currentPos = currentPos;
        notifyDataSetChanged();
    }
}
